import { createRouter, createWebHashHistory, createWebHistory } from "vue-router";
import HomeView from "@/views/HomeView.vue";
import LoginView from "@/views/LoginView.vue";
import SearchView from "@/views/SearchView.vue";
import DetailView from "@/views/DetailView.vue";
import NotFoundView from "@/views/NotFoundView.vue";
const router = createRouter({
    // history: createWebHashHistory(),
    history:createWebHistory(),
    routes: [
        {
            path:'/',
            redirect:'/home' // 如果访问的是http://localhost:5173/#/会自动重定向到home
        },
        {
            name:'home',
            path:'/home/:id?',
            // component:HomeView
            component:()=>import('@/views/HomeView.vue') //路由懒加载
        },
        {
            path:'/login',
            // component:LoginView
            component:()=>import('@/views/LoginView.vue') //路由懒加载
        },
        {
            path:'/search',
            // component:SearchView
            component:()=>import('@/views/SearchView.vue') //路由懒加载
        },
        {
            path:'/detail/:name/:index?',
            // component:DetailView
            component:()=>import('@/views/DetailView.vue') //路由懒加载
        },
        {
            path:'/counter',
            component:()=>import('@/views/CounterView.vue')
        },
        {
            path:'/anothercounter',
            component:()=>import('@/views/AnotherCount.vue')
        },
        {
            path:'/:pathMatch(.*)*',
            // component:NotFoundView
            component:()=>import('@/views/NotFoundView.vue') //路由懒加载
        }
    ] //对应鸿蒙的router_map.json
})//创建路由实例对象

export default router // 导出路由实例对象